package homework.api03.exercises01;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionDemo1 {
    public static void main(String[] args) {
        //Collection c = new HashSet();
        Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        boolean b = c.add("one");//true
        System.out.println(b);

        //集合重写了Object类的toString方法 返回格式如下
        //[元素1.toString,元素2.toString,元素3.toString]
        System.out.println(c);
        System.out.println("saize:"+c.size());//元素个数
        System.out.println("是否为空集:"+c.isEmpty());//false

        c.clear();//清空
        System.out.println(c);//[]
        System.out.println("size:"+c.size());//0
        System.out.println("是否为空集:"+c.isEmpty());//true




    }
}
